<!--
auth: 徐剑锋
-->
<html>
<head>
    <link rel="stylesheet" href="<?php echo IMG_PATH ?>admin/common.css?<?php echo STATIC_VER ?>">
    <link rel="stylesheet" href="<?php echo IMG_PATH ?>admin/bootstrap.min.css">
    <script>SITE_PATH='<?php echo SITE_PATH ?>';</script>
    <title>监控订单 - 千纸鹤管理平台</title>
    <style>
        th{font-size: 18px;text-align: center;background:#FFEC8B;}
        td{font-size: 16px;text-align: center;}
        td,th{border:1px solid #a2a2a2;}
        table{background:#F0F8FF;}
        tr:nth-of-type(3n){background:#FFFFE0;border:1px solid #a2a2a2;}
    </style>
</head>
<body style="background:#f1f4f6;">

<?php
    echo $header;
    date_default_timezone_set('PRC');
?>

<div id="body" style="min-width:100%;min-height:100%;overflow-y:hidden;">
    <div style="font-size:18px;margin:5px 0;">当前位置：报表＞＞财务 </div>
    <?php if($aqflag) { ?>
    <form action="/admin/finances/main" method="get" id="searchForm">
        <div style="width:100%;height:60px; border-bottom:1px solid gray;">

            <div style="height:60px;width:74%;float:left;">

                <div style="height:33px;width:110%;">
                    <div style="float:left;font-size:18px;margin:5px 0;">搜索条件>>  </div>
                    <div style="float:left;margin:5px 15px;">ID：<input type="text" name="wid" /></div>
                    <div style="float:left;margin:5px 15px;">工作人员姓名：<input type="text" name="wname" /></div>

                    <div style="float:left;"><input type="submit" name="search" value="搜索" /> </div>
                    <div style="float:left;"><a href="/admin/finances/main"><button>清空</button></a> </div>
                </div>
            </div>
        </div>
    </form>
    <?php } ?>
</div>
<?php if(isset($errors) || (isset($_GET['err']) && $errors=$_GET['err'])){ ?>
    <div class="alert alert-error"style="width:40%;padding: 15px 0;  text-align: center; color: red;background: pink;margin-left: 29%;margin-bottom: 10px;">
        <?php echo $errors;?>
    </div>
<?php }?>

<div style="width:100%;min-height:100%;margin-bottom:20px;">
    <table width="96%" border="0" cellpadding="0" cellspacing="0" style="margin:0 auto;border:1px solid gray;">
        <thead>
            <tr><th>工作人员ID</th><th>城市</th><th>姓名</th><th>余额</th><th>更新时间</th><th>操作</th></tr>
        </thead>
        <tbody id="listTBody">

        <?php
        if(isset($datas) && count($datas)) {
            foreach($datas as $data) { ?>
                <tr>
                    <td><?php echo $data['workerId'] ?></td>
                    <td><?php echo $data['cityName'] ?></td>
                    <td><?php echo $data['realname'] ?></td>
                    <td><?php echo $data['balance'] ?>元</td>
                    <td><?php echo date('Y-m-d H:i:s', $data['time_update']) ?></td>
                    <td style="padding:5px;">
                        <a href="/admin/finances/financesDetail?wid=<?php echo $data['workerId'];?>&wname=<?php echo $data['realname'];?>"><button class ='btn btn-info'>详情</button></a>
                        <?php if($flag) echo '<button class="btn btn-primary toPrepaid" wid="'.$data['workerId'].'"wname="'.$data['realname'].'"style="margin-left:10px">充值</button>';?>
                    </td>
                </tr>
        <?php }
        }else { ?>
            <tr>
                <td colspan="6" style="height:40px;">查无数据</td>
            </tr>

        <?php
        }
        ?>
        </tbody>
    </table>
</div>
<div style="width:100%;height:20px;">&nbsp;</div>

<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">

    <div class="modal-dialog">
        <form action="javascript:;"class="form-horizontal col-xs-10"id="form1"style="width:100%;">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">X</span></button>
                <h4 class="modal-title" id="myModalLabel">充值</h4>
            </div>

            <div class="modal-body"style="height:160px;">

                    <div class="form-group">
                        <label for="inputName"class="col-sm-3 control-label"style="font-size:16px;font-weight:normal;margin-right:0px;padding-right: 0px;">用户ID：</label>
                        <div class="col-sm-7"style="margin-left:0px;">
                            <input type="text"class="form-control"id="inputWid"name="inputWid"readonly/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="inputName"class="col-sm-3 control-label"style="font-size:16px;font-weight:normal;margin-right:0px;padding-right: 0px;">用户名：</label>
                        <div class="col-sm-7"style="margin-left:0px;">
                            <input type="text"class="form-control"id="inputWname"readonly/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="inputName"class="col-sm-3 control-label"style="font-size:16px;font-weight:normal;margin-right:0px;padding-right: 0px;">充值金额：</label>
                        <div class="col-sm-7"style="margin-left:0px;">
                            <input type="text"class="form-control"id="money"name="money"placeholder="单位为元" autocomplete="off"required/>
                        </div>
                    </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="submit" class="btn btn-primary">充值</button>
            </div>

        </div></form>
    </div>

</div>

<script src="http://static.caocaod.com/libs/jquery/jquery-2.2.3.min.js"></script>
<script src="<?php echo IMG_PATH ?>admin/common.js?<?php echo STATIC_VER ?>"></script>
<script src="<?php echo IMG_PATH ?>admin/bootstrap.min.js"></script>

<script>
<?php if($aqflag) { ?>
    $('.toPrepaid').click(function() {
        $('#myModal #inputWid').val($(this).attr('wid'));
        $('#myModal #inputWname').val($(this).attr('wname'));
        $('#myModal').modal('show');
    });


    $('#form1').submit(function() {
//        console.log($(this).serialize());
        if($('#inputWid').val().trim()=='') {
            alert('提交失败，没有选择用户');
            return false;
        }

        if($('#money').val().trim()== '' || isNaN($('#money').val())) {
            alert('提交金额不能为空且必须是数字');
            return false;
        }


        var that = $(this);
        $.ajax({
            type:'post',
            dataType:'json',
            data:$(that).serialize(),
            url:SITE_PATH + 'admin/finances/doPrepaid',
            success:function(msg) {
                $('#myModal').modal('hide');
                if(msg['result']) {
                    alert('充值成功');
                    window.location.reload();
                }else {
                    alert('充值失败，'+msg['msg']);
                }
            },
            error:function(msg) {
                $('#myModal').modal('hide');
                alert('_充值失败，请稍侯再试');
            }
        })

        return false;
    });
<?php } ?>
</script>
</body>
</html>